import { Component, OnInit } from '@angular/core';

// import { Hero } from '../hero';
// import { HEROES } from '../mock-heroes';

import { Holidays } from '../../domain/holidays';
import { HolidayService } from '../../service/holiday.service';

@Component({
  selector: 'app-staff-business-record',
  templateUrl: './staff-business-record.component.html',
  styleUrls: ['./staff-business-record.component.css']
})
export class StaffBusinessRecordComponent implements OnInit {

  // heroes = HEROES;
  // selectedHero: Hero;

  holidays : Holidays[];
  selectedHoliday : Holidays;

  onSelect(holiday: Holidays): void {
    this.selectedHoliday = holiday;
  }

  constructor(private holidayService: HolidayService) { 

  }

  ngOnInit() {
    this.holidayService.getHolidays().then((getHolidays) => {
      this.holidays = getHolidays
      for(var i = 0; i < this.holidays.length; i++) {
        // "未审批" = 0,
        // "部门经理已审批" = 1,
        // "副总经理已审批" = 2,
        // "总经理已审批" = 3
        switch (this.holidays[i].fields.status) {
          case (0):
            this.holidays[i].fields.status = "未通过";
            break;
          case (1):
            this.holidays[i].fields.status = "部门经理已审批";
            break;
          case (2):
            this.holidays[i].fields.status = "副总经理已审批";
            break;
          case (3):
            this.holidays[i].fields.status = "总经理已审批";
            break;
          default:
            this.holidays[i].fields.status = "无人过问，很惨！";
            break;
        }
      }
    }
    );
  }
}
